import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:flutter_app03/Runerrands_Order_cancel.dart';

void main() {
  runApp(MyApp());
}
class MyApp extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
      home:GetOrder(),
    );
  }

}
class GetOrder extends StatefulWidget {
  @override
  GetOrderState createState() => new GetOrderState();
}

class GetOrderState extends State<GetOrder> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        backgroundColor: Color.fromRGBO(236,236,236, 1),
        appBar: AppBar(
            backgroundColor: Color.fromRGBO(51, 51, 51, 1),
            titleSpacing: 0.0,
            title:Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                FlatButton(
                  materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
                  child: Row(
                    children: [
                      Icon(Icons.arrow_back_ios,color: Colors.white,),
                      Text('返回',style: TextStyle(color: Colors.white,fontSize: 16),)
                    ],
                  ),
                  onPressed:(){
                    Navigator.pop(context);
                  },
                ),
                Container(child: Row(children: [
                  Text('跑腿待付款详情',style: TextStyle(fontSize: 16),),
                  SizedBox(width: 25,)
                ],),),
                IconButton(icon: Icon(Icons.more_horiz), onPressed: (){})
              ],
            )
        ),
        body: Container(
          child: Column(
            children: <Widget>[
              //跑腿待付款（金额内容地址）
              Container(
                padding: EdgeInsets.only(left: 15,right: 15,top:10 ,bottom: 10),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[

                    //跑腿待付款
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: <Widget>[
                        Text("跑腿  加急",style: TextStyle(fontSize: 14),),
                        Spacer(),
                        Text("待付款",style: TextStyle(color: Colors.red,fontSize: 16),textAlign: TextAlign.right,)
                      ],
                    ),
                    SizedBox(height: 10,),
                    Text("任务主题（限制20字）",style: TextStyle(fontSize: 18),),
                    SizedBox(height: 20,),
                    //分割线
                    Divider(color: Color.fromRGBO(51, 51, 51, 0.5)),
                    //已支付
                    Row(
                      children: <Widget>[

                        Icon(Icons.attach_money,color:Color.fromRGBO(51, 51, 51, 0.5),),

                        Text("  已支付：5元",style: TextStyle(fontSize: 16))
                      ],
                    ),
                    SizedBox(height: 10,),
                    //任务内容
                    Container(
                      width: MediaQuery.of(context).size.width*0.73,//300
                      child: Row(
                        children: <Widget>[
                          Icon(Icons.message,color:Color.fromRGBO(51, 51, 51, 0.5),),
                          Expanded(
                            child: Padding(
                              padding: EdgeInsets.only(left: 10,top: 12),
                              child: Text('任务内容任务内容任务内容任务内容任务内容任务内容任务内容任务内容',style: TextStyle(fontSize: 16),),
                            ),
                          ),
                        ],
                      ),
                    ),
                    SizedBox(height: 20,),
                    //分割线
                    Divider(color: Color.fromRGBO(51, 51, 51, 0.5)),
                    //发单人姓名地址电话
                    Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: <Widget>[
                        Icon(Icons.location_on,color:Color.fromRGBO(51, 51, 51, 0.5),),
                        Text("  发单人姓名         15688888888  ",style: TextStyle(fontSize: 16)),
                      ],
                    ),
                    SizedBox(height: 8,),
                    Text("          福建省厦门市",style: TextStyle(fontSize: 13)),
                    SizedBox(height: 30,),
                    //分割线
                    Divider(color: Color.fromRGBO(51, 51, 51, 0.5)),
                    SizedBox(height: 8,),
                    //  发布时间
                    Row(
                      children: <Widget>[

                        Icon(Icons.access_time,color:Color.fromRGBO(51, 51, 51, 0.5),),

                        Text("  发布时间：2017-6-20 18:00",style: TextStyle(fontSize: 16))
                      ],
                    ),
                    SizedBox(height: 8,),
                  ],
                ),

                decoration: BoxDecoration(
                    color: Colors.white
                ),
              ),

              Spacer(),
              //取消订单
              Container(
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.end,
                  children: [
                    MaterialButton(
                        color: Color.fromRGBO(255,255,255,1),
                        child: new Text('取消订单'),
                        shape: BeveledRectangleBorder(borderRadius: BorderRadius.circular(3.0),
                            side: BorderSide(color: Colors.black,width: 0.5)),
                        onPressed: (){
                          showDialog(
                              context:context,
                              barrierDismissible: false,
                              builder: (BuildContext context){
                                return DemoDialog();
                              }
                          );
                        }
                    ),
                    SizedBox(width: 10,)
                  ],
                ),
                height: 50,
                color: Colors.white,
              ),
            ],
          ),
        ),
      ),
    );
  }

}
class DemoDialog extends StatefulWidget {
  @override
  DemoDialogState createState() => new DemoDialogState();
}

class DemoDialogState extends State<DemoDialog> {
  String dropdownValue = '原因1';
  @override
  Widget build(BuildContext context) {
    return Material(
      //创建透明层
      type: MaterialType.transparency, //透明类型
      child: new Center(
        //保证控件居中效果
        child: new SizedBox(
          width: MediaQuery.of(context).size.width*0.73,//300
          height:MediaQuery.of(context).size.height*0.27,//200
          child: Container(
            decoration: BoxDecoration(
                border: new Border.all(color: Colors.black, width: 0.5),
                color: Colors.white),
            child: Column(
              children: <Widget>[
                SizedBox(height: 10,),
                Text("取消原因",style: TextStyle(fontSize: 20),),
                SizedBox(height: 30,),
                Container(
                  width: 70,
                  height: 23,
                  decoration: BoxDecoration(
                      border: new Border.all(color: Colors.black, width: 1),
                      color: Colors.white),
                  child: DropdownButton<String>(
                    value: dropdownValue,
                    onChanged: (String newValue) {
                      setState(() {
                        dropdownValue = newValue;
                      });
                    },
                    items: <String>['原因1', '原因2', '原因3', '原因4']
                        .map<DropdownMenuItem<String>>((String value) {
                      return DropdownMenuItem<String>(
                        value: value,
                        child: Text(value),
                      );
                    })
                        .toList(),
                  ),
                ),
                Spacer(),
                Row(
                    children: <Widget>[
                      Expanded(
                        child: Container(
                          child: Center(
                            child: FlatButton(
                              highlightColor:Color.fromRGBO(255,255,255,0),
                              child: Text("确认"),
                              onPressed: (){
                                Navigator.of(context).push(new MaterialPageRoute(builder: (BuildContext context){
                                  return Runerrands_Order_cancelState();
                                }));

                              },
                            ),
                          ),
                          decoration: BoxDecoration(
                            border: new Border.all(color: Colors.black, width: 0.5),
                          ),
                        ),
                      )
                      ,
                      Expanded(
                        child: Container(
                          child: Center(
                            child: FlatButton(
                              highlightColor:Color.fromRGBO(255,255,255,0),
                              child: Text("取消"),
                              onPressed: (){
                                  Navigator.pop(context);
                              },
                            ),
                          ),
                          decoration: BoxDecoration(
                            border: new Border.all(color: Colors.black, width: 0.5),
                          ),
                        ),
                      )
                    ],
                  ),

              ],
            ),
          ),
        ),
      ),
    );
  }
}



